package com.healthtop.service.impl;

import com.healthtop.dao.XsAdviceDao;
import com.healthtop.dto.XsAdviceDto;
import com.healthtop.model.XsAdvice;
import com.healthtop.service.XsAdviceService;
import com.healthtop.utils.AjaxResponseStatus;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class XsAdviceServiceImpl implements XsAdviceService {

    @Autowired
    private XsAdviceDao xsAdvicedao;

    @Override
    public AjaxResponseStatus addAdvice(XsAdviceDto xsAdviceDto) {
        AjaxResponseStatus ajaxResponseStatus = new AjaxResponseStatus();
        try{
            XsAdvice xsAdvice = new XsAdvice();
            BeanUtils.copyProperties(xsAdviceDto,xsAdvice);
            xsAdvicedao.addAdvice(xsAdvice);
            ajaxResponseStatus.setStatusCode(200);
        }catch (Exception e){
            e.printStackTrace();
            ajaxResponseStatus.setStatusCode(500);
            ajaxResponseStatus.setMessage("意见提交失败,请重新提交");

        }
        return ajaxResponseStatus;
    }
}
